FragmentManager

Static library support version of the framework's android.app.FragmentManager. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework FragmentManager documentation for a class overview.

Your activity must derive from FragmentActivity to use this. From such an activity, you can acquire the FragmentManager by calling getSupportFragmentManager.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
interface BackStackEntry
Representation of an entry on the fragment back stack, as created with FragmentTransaction.addToBackStack().
Link copied to clipboard
Callback interface for listening to fragment state changes that happen within a given FragmentManager.
Link copied to clipboard
Interface to watch for changes to the back stack.

Properties

Link copied to clipboard
Flag for popBackStack and popBackStack: If set, and the name or ID of a back stack entry has been supplied, then all matching entries will be consumed until one that doesn't match is found or the bottom of the stack is reached.
Link copied to clipboard
val TAG: String = "FragmentManager"

Functions

Link copied to clipboard
Add a FragmentOnAttachListener that should receive a call to onAttachFragment when a new Fragment is attached to this FragmentManager.
Link copied to clipboard
Add a new listener for changes to the fragment back stack.
Link copied to clipboard
Start a series of edit operations on the Fragments associated with this FragmentManager.
Link copied to clipboard
open fun clearBackStack(@NonNull name: String)
Clears the back stack previously saved via saveBackStack.
Link copied to clipboard
Clears the stored result for the given requestKey.
Link copied to clipboard
Clears the stored FragmentResultListener for the given requestKey.
Link copied to clipboard
open fun dump(@NonNull prefix: String, @Nullable fd: FileDescriptor, @NonNull writer: PrintWriter, @Nullable args: Array<String>)
Print the FragmentManager's state into the given stream.
Link copied to clipboard
open fun enableDebugLogging(enabled: Boolean)
Control whether the framework's internal fragment manager debugging logs are turned on.
Link copied to clipboard
open fun enablePredictiveBack(enabled: Boolean)
Control whether FragmentManager uses the new state predictive back feature that allows seeing the previous Fragment when using gesture back.
Link copied to clipboard
After a FragmentTransaction is committed with FragmentTransaction.commit(), it is scheduled to be executed asynchronously on the process's main thread.
Link copied to clipboard
open fun <F : Fragment?> findFragment(@NonNull view: View): F
Find a Fragment associated with the given View.
Link copied to clipboard
Finds a fragment that was identified by the given id either when inflated from XML or as the container ID when added in a transaction.
Link copied to clipboard
Finds a fragment that was identified by the given tag either when inflated from XML or as supplied when added in a transaction.
Link copied to clipboard
Recurse up the view hierarchy, looking for a FragmentManager
Link copied to clipboard
Return the BackStackEntry at index index in the back stack; entries start index 0 being the bottom of the stack.
Link copied to clipboard
Return the number of entries currently in the back stack.
Link copied to clipboard
Retrieve the current Fragment instance for a reference previously placed with putFragment.
Link copied to clipboard
Gets the current FragmentFactory used to instantiate new Fragment instances.
Link copied to clipboard
Get a list of all fragments that are currently added to the FragmentManager.
Link copied to clipboard
Link copied to clipboard
Return the currently active primary navigation fragment for this FragmentManager.
Link copied to clipboard
Returns the current policy for this FragmentManager.
Link copied to clipboard
open fun isDestroyed(): Boolean
Returns true if the final Activity.onDestroy() call has been made on the FragmentManager's Activity, so this instance is now dead.
Link copied to clipboard
Link copied to clipboard
open fun isStateSaved(): Boolean
Returns true if the FragmentManager's state has already been saved by its host.
Link copied to clipboard
Callback for when the FragmentContainerView becomes available in the view hierarchy and the fragment manager can add the fragment view to its hierarchy.
Link copied to clipboard
open fun popBackStack()
Pop the top state off the back stack.
open fun popBackStack(id: Int, flags: Int)
Pop all back stack states up to the one with the given identifier.
open fun popBackStack(@Nullable name: String, flags: Int)
Pop the last fragment transition from the manager's fragment back stack.
Link copied to clipboard
open fun popBackStackImmediate(id: Int, flags: Int): Boolean
Like popBackStack, but performs the operation immediately inside of the call.
Link copied to clipboard
open fun putFragment(@NonNull bundle: Bundle, @NonNull key: String, @NonNull fragment: Fragment)
Put a reference to a fragment in a Bundle.
Link copied to clipboard
Registers a FragmentLifecycleCallbacks to listen to fragment lifecycle events happening in this FragmentManager.
Link copied to clipboard
Remove a listener that was previously added with addOnBackStackChangedListener.
Link copied to clipboard
open fun restoreBackStack(@NonNull name: String)
Restores the back stack previously saved via saveBackStack.
Link copied to clipboard
open fun saveBackStack(@NonNull name: String)
Save the back stack.
Link copied to clipboard
Save the current instance state of the given Fragment.
Link copied to clipboard
open fun setFragmentFactory(@NonNull fragmentFactory: FragmentFactory)
Set a FragmentFactory for this FragmentManager that will be used to create new Fragment instances from this point onward.
Link copied to clipboard
fun setFragmentResult(@NonNull requestKey: String, @NonNull result: Bundle)
Sets the given result for the requestKey.
Link copied to clipboard
Sets the FragmentResultListener for a given requestKey.
Link copied to clipboard
Sets the policy for what actions should be detected, as well as the penalty if such actions occur.
Link copied to clipboard
open fun toString(): String